package javablackbelt.main;

import javablackbelt.beans.BankService;
import javablackbelt.beans.CustomerAccount;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainTest {

	protected final static Logger logger = Logger.getLogger(MainTest.class);

	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		ApplicationContext appContext = new ClassPathXmlApplicationContext(
									"classpath:/javablackbelt/config/applicationContext.xml");
		((ConfigurableApplicationContext)appContext).registerShutdownHook();
		
		BankService bankService = (BankService) appContext.getBean("bankService");
		CustomerAccount customerAccount = (CustomerAccount) appContext.getBean("customerAccount");
		
		logger.info("The current interest rate is: " + bankService.getInterestRate());
		logger.info("\nACCOUNT REPORT\n" + bankService.generateReport(customerAccount));
	}

}
